//  调配在线主页
<template>
  <div>
    <Header 
      :userlist="userlist" 
      @changeState="changeState" 
    />
    <div class="wrapper">
      <div class="wrap">
        <Mains 
          v-if="state === 0" 
          :userlist="userlist" 
          @changeState="changeState" 
        />
        <UserSet 
          v-if="state === 1" 
          :navTab="navTab" 
          @change="change" 
          @changeState="changeState" 
        />
        <Wallet v-if="state === 2" />
        <Service v-if="state === 3" />
        <Online 
          v-if="state === 4" 
          title="复核在线" 
          timeType="复核工作时间"
          @changeState="changeState" 
        />
        <AuditRecord 
          v-if="state === 5" 
          :recordList="recordList"
          @changeState="changeState"  
        />
        <SysMessage v-if="state === 6" />
        <!-- 处方单详情 -->
        <RecordInfo 
          v-if="state === 7"
          :pCode="pCode"
          :type="5"
       />
      </div>
    </div>
    <Footer />
  </div>
</template>

<script>
import Header from "./header";
import Footer from "@/components/public/public_bottom";
import Mains from "./main"; //主页
import UserSet from "@/components/personal_repect/userData"; // 修改个人信息
import Wallet from "@/components/personal_repect/wallet/wallet"; // 我的钱包
import Service from "@/components/personal_repect/service"; // 联系客服
import Online from "@/components/personal_repect/online"; // 复核在线
import AuditRecord from "@/components/personal_repect/auditRecord"; // 审核记录
import SysMessage from "@/components/personal_repect/sysMessage";
import RecordInfo from "@/components/personal_repect/recordInfo"; // 审核详情

import { usergetinfo } from "@/request/user"; // 获取用户信息
import { getPrescriptionList } from "@/request/personnel" // 获取自己添加的问诊处方单
export default {
  components: {
    Header,
    Footer,
    Mains,
    Online,
    UserSet,
    AuditRecord,
    Wallet,
    Service,
    SysMessage,
    RecordInfo
  },
  data() {
    return {
      state: 0,
      navTab: 0,
      userlist: {},
      recordList: [], // 审核记录
      pCode: "" // 具体处方单号
    };
  },
  created() {
    usergetinfo({token: this.$token}).then(res => {
      this.userlist = res.data;
    })
    getPrescriptionList({
      token: this.$token,
      status_str: "1,2,3,4,5,6,7"
    }).then(res => {
      this.recordList = res.data.data;
    })
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      if (to.query.msg) {
        vm.state = 6;
      }
    });
  },
  methods: {
    changeState(num, pCode) {
      this.state = num;
      if (num === 2 && this.state === 2) {
        this.state = 100;
        this.$nextTick(() => {
          this.state = 2;
        });
      }
      if(num === 7) {
        this.pCode = pCode;
      }
    },
    change(num) {
      this.navTab = num;
    }
  }
};
</script>

<style scoped>
.wrap {
  width: 1200px;
  margin: 0 auto;
}
.wrapper {
  background: #f5f5f5;
  padding: 40px 0px;
}
</style>